﻿using BLL;
using BLL.Access;
using DevExpress.Web;
using Entity;
using System;
using System.Data;
using System.IO;
using Web.Class;
using System.Data.OleDb;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web.Pages.QuShui.DiXiaS._7.ChaXunGL
{
    public partial class QuShuiGuaHaoXin : System.Web.UI.Page
    {
        #region 属性
        /// <summary>
        /// 是否重新加载数据
        /// </summary>
        public int IsReloadTable
        {
            get
            {
                return ViewState["IsReloadTable"] == null ? 0 : Convert.ToInt32(ViewState["IsReloadTable"]);
            }
            set
            {
                ViewState["IsReloadTable"] = value;
            }
        }
        private int _PageIndex7;

        public int PageIndex7
        {
            get { return HiddenListValue.Contains("_PageIndex7") ? Convert.ToInt32(HiddenListValue.Get("_PageIndex7")) : 0; }
            set { HiddenListValue.Set("_PageIndex7", value); }
        }


        private int PageSize7 = 50;
        /// <summary>
        /// 保存结果集1
        /// </summary>
        private DataTable dtBenQiXXTab1
        {
            get
            {
                return ViewState["dtBenQiXXTab1"] as DataTable;
            }
            set
            {
                ViewState["dtBenQiXXTab1"] = value;
            }
        }

        /// <summary>
        /// 保存结果集2
        /// </summary>
        private DataTable dtBenYueDZTab2
        {
            get
            {
                return ViewState["dtBenYueDZTab2"] as DataTable;
            }
            set
            {
                ViewState["dtBenYueDZTab2"] = value;
            }
        }

        /// <summary>
        /// 保存结果集3
        /// </summary>
        private DataTable dtTuiPiaotab3
        {
            get
            {
                return ViewState["dtTuiPiaotab3"] as DataTable;
            }
            set
            {
                ViewState["dtTuiPiaotab3"] = value;
            }
        }
        /// <summary>
        /// 保存结果集4
        /// </summary>
        private DataTable dtTuiKuantab4
        {
            get
            {
                return ViewState["dtTuiKuantab4"] as DataTable;
            }
            set
            {
                ViewState["dtTuiKuantab4"] = value;
            }
        }

        /// <summary>
        /// 保存结果集5
        /// </summary>
        private DataTable dtJiHuaBGtab5
        {
            get
            {
                return ViewState["dtJiHuaBGtab5"] as DataTable;
            }
            set
            {
                ViewState["dtJiHuaBGtab5"] = value;
            }
        }

        /// <summary>
        /// 保存结果集6
        /// </summary>
        private DataTable dtDuoShoutab6
        {
            get
            {
                return ViewState["dtDuoShoutab6"] as DataTable;
            }
            set
            {
                ViewState["dtDuoShoutab6"] = value;
            }
        }
        /// <summary>
        /// 保存结果集7
        /// </summary>
        private DataTable dtGuaHaoXtab7
        {
            get
            {
                return ViewState["dtGuaHaoXtab7"] as DataTable;
            }
            set
            {
                ViewState["dtGuaHaoXtab7"] = value;
            }
        }
        /// <summary>
        /// 保存结果集8
        /// </summary>
        private DataTable dtJiaoFeitab8
        {
            get
            {
                return ViewState["dtJiaoFeitab8"] as DataTable;
            }
            set
            {
                ViewState["dtJiaoFeitab8"] = value;
            }
        }


        /// <summary>
        /// 当前操作项ID
        /// </summary>
        private int yonghuXXTab1_ID
        {
            get
            {
                return Convert.ToInt32(ViewState["yonghuXXTab1_ID"]);
            }
            set
            {
                ViewState["yonghuXXTab1_ID"] = value;
            }
        }
        /// <summary>
        /// 当前操作项ID
        /// </summary>
        private int yonghuXXTab2_ID
        {
            get
            {
                return Convert.ToInt32(ViewState["yonghuXXTab2_ID"]);
            }
            set
            {
                ViewState["yonghuXXTab2_ID"] = value;
            }
        }

        #endregion

        #region 变量

        /// <summary>
        /// 用户信息
        /// </summary>
        YS_YG_YONGHUXX _YS_YG_YONGHUXX = new YS_YG_YONGHUXX();

        /// <summary>
        /// 用户信息bll
        /// </summary>
        YS_YG_YONGHUXXBLL _YS_YG_YONGHUXXBLL = new YS_YG_YONGHUXXBLL();

        /// <summary>
        /// 管理部门
        /// </summary>
        YS_JX_ZHANDIAN _YS_JX_ZHANDIAN = new YS_JX_ZHANDIAN();

        /// <summary>
        /// 管理部门bll
        /// </summary>
        YS_JX_ZHANDIANBLL _YS_JX_ZHANDIANBLL = new YS_JX_ZHANDIANBLL();

        /// <summary>
        /// 管理块
        /// </summary>
        YS_JX_GUANLIK _YS_JX_GUANLIK = new YS_JX_GUANLIK();

        /// <summary>
        /// 管理块BLL
        /// </summary>
        YS_JX_GUANLIKBLL _YS_JX_GUANLIKBLL = new YS_JX_GUANLIKBLL();

        /// <summary>
        /// 局信息BLL
        /// </summary>
        YS_JX_JUXINXBLL _YS_JX_JUXINXBLL = new YS_JX_JUXINXBLL();

        /// <summary>
        /// 公司信息BLL
        /// </summary>
        YS_JX_GONGSIXXBLL _YS_JX_GONGSIXXBLL = new YS_JX_GONGSIXXBLL();

        /// <summary>
        /// 行政区bll
        /// </summary>
        YS_JX_XINGZHENGQBLL _YS_JX_XINGZHENGQBLL = new YS_JX_XINGZHENGQBLL();
        /// <summary>
        /// 配置表bll
        /// </summary>
        S_WORDSBLL _S_WORDSBLL = new S_WORDSBLL();
        /// <summary>
        /// 存储过程调用类
        /// </summary>
        SpHelper _SpHelper = new SpHelper();
        BLL.SqlHelper _SplHelper = new BLL.SqlHelper();

        public int m_CurrentUserID = LoginInfo.CurrentUser.UserID;

        #endregion

        #region 事件

        /// <summary>
        /// 页面加载事件
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {

            //第一次页面加载
            if (!IsPostBack)
            {
                InitData();
            }


            int index = ASPxPageControl1.ActiveTabIndex;

            gvBenQiXXTab1.DataSource = this.dtBenQiXXTab1;
            gvBenQiXXTab1.DataBind();

            this.gvBenYueDZtab2.DataSource = this.dtBenYueDZTab2;
            this.gvBenYueDZtab2.DataBind();

            this.gvTuiPiaotab3.DataSource = this.dtTuiPiaotab3;
            this.gvTuiPiaotab3.DataBind();

            this.gvTuiKuantab4.DataSource = this.dtTuiKuantab4;
            this.gvTuiKuantab4.DataBind();

            this.gvJiHuaBGtab5.DataSource = this.dtJiHuaBGtab5;
            this.gvJiHuaBGtab5.DataBind();

            this.gvDuoShoutab6.DataSource = this.dtDuoShoutab6;
            this.gvDuoShoutab6.DataBind();

            this.gvGuaHaoXtab7.DataSource = this.dtGuaHaoXtab7;
            this.gvGuaHaoXtab7.DataBind();

            gvJiaoFeitab8.DataSource = dtJiaoFeitab8;
            gvJiaoFeitab8.DataBind();




            if (index == 1 || index == 2 || index == 3)
            {
                cmbZhangWuY2.ClientEnabled = true;
                cmbZhangWuM2.ClientEnabled = true;
            }

        }



        /// <summary>
        /// 查询信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnChaXun_Click(object sender, EventArgs e)
        {
            PageIndex7 = 0;
            int index = ASPxPageControl1.ActiveTabIndex;
            //if (index != 6)
            {
                ActiveTabIndexChange(index);
            }

        }

        /// <summary>
        /// 管理部门下拉改变事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void cmbGuanLiBM_SelectedIndexChanged(object sender, EventArgs e)
        {
            cmbGuanLiK.Items.Clear();
            cmbGuanLiK.Items.Add("全部", "");
            cmbGuanLiK.SelectedIndex = 0;
            string glbm_now = cmbGuanLiBM.Value != null ? cmbGuanLiBM.Value.ToString() : "全部";
            InitDataAgain(glbm_now);
        }

        /// <summary>
        /// 表格点击行事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvYongHuXXTab1_FocusedRowChanged(object sender, EventArgs e)
        {
            //if (this.dtYongHuXXTab1 != null && this.dtYongHuXXTab1.Rows.Count > 0)
            //{
            //    this.yonghuXXTab1_ID = Convert.ToInt32(this.gvYongHuXXTab1.GetRowValues(this.gvYongHuXXTab1.FocusedRowIndex, "ID"));
            //    SetData();
            //}
        }

        /// <summary>
        /// tab2下拉框改变事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void cmbHuJiGDLX_SelectedIndexChanged(object sender, EventArgs e)
        {
            //LoadGridDataTab2();
        }

        //加载多收查询多收处理
        protected void gvDuoShou_DuoShouCLtab6_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
        {
            if (e.Parameters == "") return;
            string[] valus = e.Parameters.Split(',');
            this.gvDuoShou_DuoShouCLtab6.DataSource = _SpHelper.P_YSCX_DUOSHOUCL(valus[0], Convert.ToInt32(valus[1])).Tables[0];
            this.gvDuoShou_DuoShouCLtab6.DataBind();
        }

        #endregion

        #region 方法

        /// <summary>
        /// 初始化数据
        /// </summary>
        private void InitData()
        {
            gvBenQiXXTab1.SettingsPager.Mode = GridViewPagerMode.EndlessPaging;
            gvBenYueDZtab2.SettingsPager.Mode = GridViewPagerMode.EndlessPaging;
            gvTuiPiaotab3.SettingsPager.Mode = GridViewPagerMode.EndlessPaging;
            gvTuiKuantab4.SettingsPager.Mode = GridViewPagerMode.EndlessPaging;
            gvGuaHaoXtab7.SettingsPager.Mode = GridViewPagerMode.EndlessPaging;

            //水量年月
            string water_y_m = BusinessTool.YS_GETSETTINGSVALUE(eSETTINGS_KEYNAME.WATER_Y_M.ToString());
            //this.i_ym = Convert.ToInt32(water_y_m);
            //管理部门
            DataTable dtGuanLiBM = _YS_JX_ZHANDIANBLL.SelectYS_JX_ZHANDIANsAll();
            for (int i = 0; i < dtGuanLiBM.Rows.Count; i++)
            {
                if (dtGuanLiBM.Rows[i]["S_ZHANDIANMC"].ToString() != "中心")
                {
                    cmbGuanLiBM.Items.Add(dtGuanLiBM.Rows[i]["S_ZHANDIANMC"].ToString(), dtGuanLiBM.Rows[i]["S_ZHANDIANBH"].ToString());
                }
            }
            //业务员
            LoadYWY();
            // 加载账务年月
            LoadZWYM();
            WordsManager manger = new WordsManager();
            PageTools.BindComboBox(this.cbmJiaoFeiLXtab8, manger.Instance.FindWordsDataTableByBelongID(WordsStruct.BelongID.收费类型));
            int userid = LoginInfo.CurrentUser.UserID;
            string username = LoginInfo.CurrentUser.UserName;
            //根据操作人加载管理部门(站点)
            DataTable dtZhanDian = BusinessTool.GetTextAndValue("View_AS_UserInfo", "ZHANDIANBH", "ROLEID", null, string.Format("USERID={0}", userid)).Tables[0];
            string zhandian = dtZhanDian.Rows[0]["TEXT"].ToString();//站点
            string roleid = dtZhanDian.Rows[0]["VALUE"].ToString();//9001 业务员，3001 办事处主任
            if (roleid == "9001")
            {
                if (zhandian == "00")
                {
                    //cmbYeWuY.Enabled = false;
                    cmbYeWuY.Text = username;
                }
                else
                {
                    cmbGuanLiBM.Enabled = false;
                    //cmbYeWuY.Enabled = false;
                    cmbGuanLiBM.Value = zhandian;
                    LoadYWY();
                    cmbYeWuY.Text = username;
                    //管理块
                    DataTable dtGuanLiK = _YS_JX_GUANLIKBLL.SelectYS_JX_GUANLIKsDynamic(string.Format("S_ZHANDIAN={0}", zhandian), null);
                    for (int i = 0; i < dtGuanLiK.Rows.Count; i++)
                    {
                        cmbGuanLiK.Items.Add(dtGuanLiK.Rows[i]["S_GUANLIKMC"].ToString(), dtGuanLiK.Rows[i]["S_GUANLIKH"].ToString());
                    }
                }
            }
            else if (roleid == "3001" || roleid == "4001")
            {
                cmbGuanLiBM.Enabled = false;
                cmbGuanLiBM.Value = zhandian;
                //管理块
                DataTable dtGuanLiK = _YS_JX_GUANLIKBLL.SelectYS_JX_GUANLIKsDynamic(string.Format("S_ZHANDIAN={0}", zhandian), null);
                for (int i = 0; i < dtGuanLiK.Rows.Count; i++)
                {
                    cmbGuanLiK.Items.Add(dtGuanLiK.Rows[i]["S_GUANLIKMC"].ToString(), dtGuanLiK.Rows[i]["S_GUANLIKH"].ToString());
                }
                LoadYWY();
            }
        }
        /// <summary>
        /// 加载账务年月
        /// </summary>
        private void LoadZWYM()
        {
            int zwym = BusinessTool.GetZWYM();
            int zwy = zwym / 100;
            int zwm = zwym % 100;
            if (12 == zwm)
            {
                cmbZhangWuY.Items.Add((zwy + 1).ToString(), (zwy + 1).ToString());
                cmbZhangWuY2.Items.Add((zwy + 1).ToString(), (zwy + 1).ToString());
            }
            for (int i = zwy; i >= zwy - 10; i--)
            {
                cmbZhangWuY.Items.Add(i.ToString(), i.ToString());
                cmbZhangWuY2.Items.Add(i.ToString(), i.ToString());
                if (i == zwy) cmbZhangWuY.SelectedIndex = cmbZhangWuY2.SelectedIndex = i;
            }
            for (int i = 12; i >= 1; i--)
            {
                cmbZhangWuM.Items.Add(i.ToString(), i.ToString());
                cmbZhangWuM2.Items.Add(i.ToString(), i.ToString());
            }
            //cmbZhangWuY.SelectedIndex = cmbZhangWuY2.SelectedIndex = 1;
            cmbZhangWuM.SelectedIndex = 13 - zwm;
            cmbZhangWuM2.SelectedIndex = 13 - zwm;
        }

        /// <summary>
        /// 根据站点加载业务员
        /// </summary>
        private void LoadYWY()
        {
            DataTable dtYWY = BusinessTool.GetTextAndValue(
                "View_AS_UserInfo", "USERNAME", "USERID", null, this.cmbGuanLiBM.SelectedIndex == 0 ? "ROLENAME like '%业务员%' and department!=313" : string.Format("ZHANDIANBH='{0}' and ROLENAME like '%业务员%' and department!=313", this.cmbGuanLiBM.Value)
                 ).Tables[0];
            DataRow drTemp = dtYWY.NewRow();
            drTemp[0] = "";
            drTemp[1] = 0;
            dtYWY.Rows.InsertAt(drTemp, 0);
            PageTools.BindComboBox(
                this.cmbYeWuY, dtYWY
            );
            if (this.cmbYeWuY.Items.Count != 0)
            {
                this.cmbYeWuY.SelectedIndex = 0;
            }
        }

        /// <summary>
        /// 再次根据管理部门初始化查询条件
        /// </summary>
        /// <param name="glbm">管理部门</param>
        private void InitDataAgain(string glbm)
        {
            if (glbm != "全部")
            {
                //管理块
                DataTable dtGuanLiK = _YS_JX_GUANLIKBLL.SelectYS_JX_GUANLIKsDynamic(string.Format("S_ZHANDIAN={0}", glbm), null);
                for (int i = 0; i < dtGuanLiK.Rows.Count; i++)
                {
                    cmbGuanLiK.Items.Add(dtGuanLiK.Rows[i]["S_GUANLIKMC"].ToString(), dtGuanLiK.Rows[i]["S_GUANLIKH"].ToString());
                }
                //业务员
                LoadYWY();
            }
            else
            {
                cmbYeWuY.Items.Clear();
                //业务员
                LoadYWY();
            }
        }

        /// <summary>
        /// 跟当前显示的tab也签选择查询的数据集
        /// </summary>
        /// <param name="index">当前选项卡的索引</param>
        private void ActiveTabIndexChange(int index)
        {
            int v_zwy = cmbZhangWuY.Text == "全部" ? 0 : Convert.ToInt32(cmbZhangWuY.Value);
            int v_zwm = cmbZhangWuM.Text == "全部" ? 0 : Convert.ToInt32(cmbZhangWuM.Value);
            int v_zwy2 = cmbZhangWuY2.Text == "全部" ? 0 : Convert.ToInt32(cmbZhangWuY2.Value);
            int v_zwm2 = cmbZhangWuM2.Text == "全部" ? 0 : Convert.ToInt32(cmbZhangWuM2.Value);
            int v_zwym1 = 0, v_zwym2 = 0;

            v_zwym1 = v_zwy != 0 && v_zwm != 0 ? v_zwy * 100 + v_zwm : 0;
            v_zwym2 = v_zwy2 != 0 && v_zwm2 != 0 ? v_zwy2 * 100 + v_zwm2 : 0;

            if (v_zwy != 0 && v_zwy2 != 0 && (v_zwm == 0 || v_zwm2 == 0))
            {
                v_zwym1 = (v_zwy * 100) + 1;
                v_zwym2 = (v_zwy * 100) + 12;

            }

            string v_zhandian = null, v_guanlikuai = null, v_ywy = cmbYeWuY.Text == "" ? null : Convert.ToString(cmbYeWuY.Value);
            string type = "";
            string value = "";
            //站点
            if (cmbGuanLiBM.Value != null)
            {
                v_zhandian = cmbGuanLiBM.Value.ToString();
            }
            //管理块
            if (cmbGuanLiK.Value != null)
            {
                v_guanlikuai = cmbGuanLiK.Value.ToString();
            }

            // 水量年月 用户号、用户名、
            if (rbnShuiLiangYM.Checked && cmbShuiLiangYM1.Text != "" && txtShuiLiangYM2.Text != "")
            {
                type = "v_ym";
                value = cmbShuiLiangYM1.Text + txtShuiLiangYM2.Text;
            }
            else if (rbnYongHuH.Checked && txtYongHuH.Text.Trim() != "")
            {
                type = "v_yonghuh";
                value = txtYongHuH.Text;
            }
            else if (rbnYongHuM.Checked && txtYongHuM.Text.Trim() != "")
            {
                type = "v_yonghum";
                value = txtYongHuM.Text;
            }
            switch (index)
            {
                case 0:
                    LoadGridDataTab1(v_zwy, v_zwm, v_zhandian, v_guanlikuai, v_ywy, type, value);
                    break;
                case 1:
                    LoadGridDataTab2(v_zwym1, v_zwym2, v_zhandian, v_guanlikuai, v_ywy, type, value);
                    break;
                case 2:
                    LoadGridDataTab3(v_zwym1, v_zwym2, v_zhandian, v_guanlikuai, v_ywy, type, value);
                    break;
                case 3:
                    LoadGridDataTab4(v_zwym1, v_zwym2, v_zhandian, v_guanlikuai, v_ywy, type, value);
                    break;
                case 4:
                    LoadGridDataTab5(v_zwy, v_zwm, v_zhandian, v_guanlikuai, v_ywy, type, value);
                    break;
                case 5:
                    LoadGridDataTab6(v_zwy, v_zwm, v_zhandian, v_guanlikuai, v_ywy, type, value);
                    break;
                case 6:
                    LoadGridDataTab7(v_zwy, v_zwm, v_zhandian, v_guanlikuai, v_ywy, type, value);
                    break;
                case 7:
                    LoadGridDataTab8(v_zwy, v_zwm, v_zhandian, v_guanlikuai, v_ywy, type, value);
                    break;
                default: break;
            }
        }
        /// <summary>
        /// 加载查询数据
        /// </summary>
        private void LoadGridDataTab1(int v_zwy, int v_zwm, string v_zhandian, string v_guanlikuai, string v_ywy, string type, string value)
        {
            v_zhandian = v_zhandian == null ? "" : v_zhandian;
            v_guanlikuai = v_guanlikuai == null ? "" : v_guanlikuai;
            if (type == "v_yonghuh")
            {
                type = "1";
            }
            else if (type == "v_yonghum")
            {
                type = "2";
            }
            else if (type == "v_ym")
            {
                type = "6";
            }
            v_ywy = cmbYeWuY.Value.ToString() == "0" ? "" : cmbYeWuY.Value.ToString();
            string jelx = null;
            if (rbnJinECXtab1.Checked && cmbJinECXtab1.Text != "" && cmbJinECX2tab1.Text != "" && txtJinECXtab1.Text != "")
            {
                jelx = "AND  " + cmbJinECXtab1.Value.ToString() + cmbJinECX2tab1.Text + txtJinECXtab1.Text;
                // je = cmbJinECX2tab1.Text + txtJinECXtab1.Text;
            }
            //是否勾选欠费
            int sfqf = chkQianFeitab1.Checked ? 1 : 0;
            this.dtBenQiXXTab1 = SearchSpHelper.P_YS_CX_BENQIXX(v_zwy.ToString(), v_zwm.ToString(), v_zhandian, v_guanlikuai, v_ywy, type, value, jelx, sfqf).Tables[0];
            this.gvBenQiXXTab1.DataSource = this.dtBenQiXXTab1;
            this.gvBenQiXXTab1.DataBind();
            double kzje = 0, ssje = 0, hxje = 0, qf = 0, ds = 0;
            if (this.dtBenQiXXTab1 != null && this.dtBenQiXXTab1.Rows.Count > 0)
            {
                for (int i = 0; i < dtBenQiXXTab1.Rows.Count; i++)
                {
                    kzje += Convert.ToDouble(dtBenQiXXTab1.Rows[i]["N_CHUKAIJE"]);
                    ssje += Convert.ToDouble(dtBenQiXXTab1.Rows[i]["N_SHISHOUJE"]);
                    hxje += Convert.ToDouble(dtBenQiXXTab1.Rows[i]["N_QIANFEITZ"]);
                    qf += Convert.ToDouble(dtBenQiXXTab1.Rows[i]["N_QIANFEI"]);
                    ds += Convert.ToDouble(dtBenQiXXTab1.Rows[i]["N_DUOSHOU"]);
                }

            }
            lbZongYeStab1.Text = "共" + this.dtBenQiXXTab1.Rows.Count.ToString() + "条";
            txtKaiZhangJEtab1.Text = kzje.ToString("0.00");
            txtShiShouJEtab1.Text = ssje.ToString("0.00");
            txtHeXiaoJEtab1.Text = hxje.ToString("0.00");
            txtQianFeitab1.Text = qf.ToString("0.00");
            txtDuoShoutab1.Text = ds.ToString("0.00");
        }

        /// <summary>
        /// 加载tab2页签数据
        /// </summary>
        private void LoadGridDataTab2(int v_zwym1, int v_zwym2, string v_zhandian, string v_guanlikuai, string v_ywy, string type, string value)
        {
            //string type2 = "", value2 = "";
            v_ywy = cmbYeWuY.Value.ToString() == "0" ? "" : cmbYeWuY.Value.ToString();
            //if (type == "v_yonghuh")
            //{
            //    type = "1";
            //}
            //else if (type == "v_yonghuh")
            //{
            //    type = "2";
            //}
            //else if (type == "v_ym")
            //{
            //    type = "6";
            //}

            //if (rbnDaoZhangFLtab2.Checked && cmbChaoBiaoBMtab2.Text != "")//到账分类
            //{
            //    type2 = "5";
            //    value2 = cmbChaoBiaoBMtab2.Value.ToString();
            //}
            //else if (rbnShouFeiFStab2.Checked && cmbShuiLiangYtab2.Text != "")//收费方式
            //{
            //    type2 = "3";
            //    value2 = cmbShuiLiangYtab2.Value.ToString();
            //}
            //else if (rbnShouFeiJEtab2.Checked && cmbShouFeiFStab2.Text != "" && txtShouFeiFStab2.Text != "")//收费金额
            //{
            //    type2 = "4";
            //    value2 = cmbShouFeiFStab2.Text + txtShouFeiFStab2.Text;
            //}
            string v_ym = null, v_yhh = null, v_yhm = null, v_dzfl = null, v_sffs = null, v_je = null;

            if (rbnShuiLiangYM.Checked && cmbShuiLiangYM1.Text != "" && txtShuiLiangYM2.Text != "")
            {
                v_ym = cmbShuiLiangYM1.Text + txtShuiLiangYM2.Text;
            }
            if (rbnYongHuH.Checked && txtYongHuH.Text != "")
            {
                v_yhh = txtYongHuH.Text;
            }
            if (rbnYongHuM.Checked && txtYongHuM.Text != "")
            {
                v_yhm = txtYongHuM.Text;
            }
            if (rbnDaoZhangFLtab2.Checked && cmbChaoBiaoBMtab2.Text != "")
            {
                v_dzfl = cmbChaoBiaoBMtab2.Value.ToString();
            }
            if (rbnShouFeiFStab2.Checked && cmbShuiLiangYtab2.Text != "")
            {
                v_sffs = cmbShuiLiangYtab2.Value.ToString();
            }
            if (rbnShouFeiJEtab2.Checked && cmbShouFeiFStab2.Text != "" && txtShouFeiFStab2.Text != "")
            {
                v_je = cmbShouFeiFStab2.Text + txtShouFeiFStab2.Text;
            }

            //是否排除上月预收
            int pcsyys = chkPaiChuSYYStab2.Checked ? 1 : 0;
            //是否包含上月预收
            int bhsyys = chkBaoHanSYYStab2.Checked ? 1 : 0;
            //this.dtBenYueDZTab2 = SearchSpHelper.P_YS_CX_BENQIDZ(v_zwym1, v_zwym2, v_zhandian, v_guanlikuai, v_ywy, type, value, type2, value2, pcsyys, bhsyys).Tables[0];
            this.dtBenYueDZTab2 = SearchSpHelper.P_YSCX_BENYUEDZ(v_zwym1, v_zwym2, v_zhandian, v_guanlikuai, v_ywy, v_ym, v_yhh, v_yhm, v_dzfl, v_sffs, pcsyys, bhsyys, v_je).Tables[0];
            this.gvBenYueDZtab2.DataSource = this.dtBenYueDZTab2;
            this.gvBenYueDZtab2.DataBind();
            double zje = 0;
            if (dtBenYueDZTab2 != null && dtBenYueDZTab2.Rows.Count > 0)
            {
                for (int i = 0; i < dtBenYueDZTab2.Rows.Count; i++)
                {
                    zje += Convert.ToDouble(dtBenYueDZTab2.Rows[i]["N_SFJE"]);
                }
            }
            lbZongYeStab2.Text = "共" + this.dtBenYueDZTab2.Rows.Count.ToString() + "条";
            txtShouFeiJEHZtab2.Text = zje.ToString();
        }

        /// <summary>
        /// 加载tab3页签数据
        /// </summary>
        private void LoadGridDataTab3(int v_zwym1, int v_zwym2, string v_zhandian, string v_guanlikuai, string v_ywy, string type, string value)
        {
            v_ywy = cmbYeWuY.Value.ToString() == "0" ? "" : cmbYeWuY.Value.ToString();
            if (type == "v_yonghuh")
            {
                type = "1";
            }
            else if (type == "v_yonghum")
            {
                type = "2";
            }
            else if (type == "v_ym")
            {
                type = "4";
            }
            string type2 = "", value2 = "";
            if (rbnTuiPiaoJEtab3.Checked && cmbTuiPiaoJEtab3.Text != "" && txtTuiPiaoJEtab3.Text != "")
            {
                type2 = "3";
                value2 = cmbTuiPiaoJEtab3.Text + txtTuiPiaoJEtab3.Text;
            }
            //是否手工退票
            int sgtp = chkShouGongTPtab3.Checked ? 1 : 0;
            this.dtTuiPiaotab3 = SearchSpHelper.P_YS_CX_BENQITP(v_zwym1, v_zwym2, v_zhandian, v_guanlikuai, v_ywy, type, value, type2, value2, sgtp).Tables[0];
            this.gvTuiPiaotab3.DataSource = this.dtTuiPiaotab3;
            this.gvTuiPiaotab3.DataBind();
            double zje = 0;
            if (this.dtTuiPiaotab3 != null && this.dtTuiPiaotab3.Rows.Count > 0)
            {
                for (int i = 0; i < this.dtTuiPiaotab3.Rows.Count; i++)
                {
                    zje += Convert.ToDouble(dtTuiPiaotab3.Rows[i]["N_TUIPIAOJE"]);
                }
            }
            lbZongYeStab3.Text = "共" + this.dtTuiPiaotab3.Rows.Count.ToString() + "条";
            txtTuiPiaoJEHZtab3.Text = zje.ToString();
        }
        /// <summary>
        /// 加载tab4页签数据
        /// </summary>
        private void LoadGridDataTab4(int v_zwym1, int v_zwym2, string v_zhandian, string v_guanlikuai, string v_ywy, string type, string value)
        {
            v_ywy = cmbYeWuY.Value.ToString() == "0" ? "" : cmbYeWuY.Value.ToString();
            if (type == "v_yonghuh")
            {
                type = "1";
            }
            else if (type == "v_yonghum")
            {
                type = "2";
            }
            else if (type == "v_ym")
            {
                type = "5";
            }
            string type2 = "", value2 = "";
            if (rbnTuiPiaoJEtab4.Checked && cbmTuiPiaoJEtab4.Text != "" && txtTuiPiaoJE2tab4.Text != "")
            {
                type2 = "4";
                value2 = cbmTuiPiaoJEtab4.Text + txtTuiPiaoJE2tab4.Text;
            }
            else if (rbnTuiKuanLEtab4.Checked && cbmTuiKuanLEtab4.Text != "")
            {
                type2 = "3";
                value2 = cbmTuiKuanLEtab4.Value.ToString();
            }
            else if (rbnLaiHanBHtab4.Checked && txtLaiHanBHtab4.Text != "")
            {
                type2 = "6";
                value2 = txtLaiHanBHtab4.Text;
            }
            this.dtTuiKuantab4 = SearchSpHelper.P_YS_CX_TUIKUAN(v_zwym1, v_zwym2, v_zhandian, v_guanlikuai, v_ywy, type, value, type2, value2).Tables[0];
            this.gvTuiKuantab4.DataSource = this.dtTuiKuantab4;
            this.gvTuiKuantab4.DataBind();
            double zje = 0;
            if (this.dtTuiKuantab4 != null && this.dtTuiKuantab4.Rows.Count > 0)
            {
                for (int i = 0; i < this.dtTuiKuantab4.Rows.Count; i++)
                {
                    zje += Convert.ToDouble(dtTuiKuantab4.Rows[i]["N_TIAOZHENGJE"]);
                }
            }
            lbZongYeStab4.Text = "共" + this.dtTuiKuantab4.Rows.Count.ToString() + "条";
            txtTuiKuanHJtab4.Text = zje.ToString();
        }

        /// <summary>
        /// 加载tab5页签数据
        /// </summary>
        private void LoadGridDataTab5(int v_zwy, int v_zwm, string v_zhandian, string v_guanlikuai, string v_ywy, string type, string value)
        {
            string hxje = null, lhbh = null;
            if (rbnHeXiaoJEtab5.Checked && cbmHeXiaoJEtab5.Text != "" && txtHeXiaoJEtab5.Text != "")
            {
                hxje = txtHeXiaoJEtab5.Text;
            }
            else if (rbnLaiHanBHtab5.Checked && txtLaiHanBHtab5.Text != "")
            {
                lhbh = txtLaiHanBHtab5.Text;
            }
            this.dtJiHuaBGtab5 = _SpHelper.P_YSCX_JIHUABG(v_zwy == 0 ? null : (int?)v_zwy,
                                                          v_zwm == 0 ? null : (int?)v_zwm,
                                                          v_zhandian,
                                                          v_guanlikuai,
                                                          v_ywy == null ? null : (int?)Convert.ToInt32(v_ywy),
                                                          this.cmbShuiLiangYM1.Text,
                                                          !this.rbnShuiLiangYM.Checked ? null : (int?)Convert.ToInt32(this.txtShuiLiangYM2.Text),
                                                          !this.rbnYongHuH.Checked ? null : this.txtYongHuH.Text,
                                                          !this.rbnYongHuM.Checked ? null : this.txtYongHuM.Text,
                                                          this.cbmHeXiaoJEtab5.Text,
                                                          hxje == null ? null : (decimal?)Convert.ToDecimal(hxje),
                                                          lhbh
                ).Tables[0];
            this.gvJiHuaBGtab5.DataSource = this.dtJiHuaBGtab5;
            this.gvJiHuaBGtab5.DataBind();
            this.lbZongYeStab5.Text = "共" + this.dtJiHuaBGtab5.Rows.Count + "条";
            decimal jineSum = 0;
            for (int i = 0; i < this.dtJiHuaBGtab5.Rows.Count; i++)
            {
                jineSum = jineSum + Convert.ToDecimal(this.dtJiHuaBGtab5.Rows[i]["N_HEXIAOJE"]);
            }
            this.txtHeXiaoJEHZtab5.Text = jineSum.ToString("0.00");
        }

        /// <summary>
        /// 加载tab6页签数据
        /// </summary>
        private void LoadGridDataTab6(int v_zwy, int v_zwm, string v_zhandian, string v_guanlikuai, string v_ywy, string type, string value)
        {
            this.dtDuoShoutab6 = SearchSpHelper.P_YSCX_DUOSHOU(v_zwy == 0 ? null : (int?)v_zwy,
                                                         v_zwm == 0 ? null : (int?)v_zwm,
                                                         v_zhandian,
                                                         v_guanlikuai,
                                                         v_ywy == null ? null : (int?)Convert.ToInt32(v_ywy),
                                                         this.cmbShuiLiangYM1.Text,
                                                         !this.rbnShuiLiangYM.Checked ? null : (int?)Convert.ToInt32(this.txtShuiLiangYM2.Text),
                                                         !this.rbnYongHuH.Checked ? null : this.txtYongHuH.Text,
                                                         !this.rbnYongHuM.Checked ? null : this.txtYongHuM.Text,
                                                         CbxNotFP.Checked ? 1 : 0
               ).Tables[0];
            this.gvDuoShoutab6.DataSource = this.dtDuoShoutab6;
            this.gvDuoShoutab6.DataBind();
            lbZongBiStab6.Text = "共" + this.dtDuoShoutab6.Rows.Count + "笔";
            //清空子列表

            decimal jineSum = 0;
            for (int i = 0; i < this.dtDuoShoutab6.Rows.Count; i++)
            {
                jineSum = jineSum + Convert.ToDecimal(this.dtDuoShoutab6.Rows[i]["n_duoshouje"]);
            }
            this.txtDuoShouJEHZtab6.Text = jineSum.ToString("0.00");
            decimal jineSumOK = 0;
            //获取已处理金额
            for (int i = 0; i < this.dtDuoShoutab6.Rows.Count; i++)
            {
                jineSumOK = jineSumOK + Convert.ToDecimal(_SpHelper.P_YSCX_DUOSHOUYCLJE(this.dtDuoShoutab6.Rows[i]["S_YONGHUH"].ToString(), Convert.ToInt32(this.dtDuoShoutab6.Rows[i]["I_YM"])).Tables[0].Rows[0][0]);
            }
            this.txtWeiChuLJEHZtab6.Text = (jineSum - jineSumOK).ToString("0.00");

        }

        /// <summary>
        /// 加载tab7页签数据
        /// </summary>
        private void LoadGridDataTab7(int v_zwy, int v_zwm, string v_zhandian, string v_guanlikuai, string v_ywy, string type, string value)
        {
            //this.gvGuaHaoXtab7
            int ym = 0;
            if (int.TryParse(txtShuiLiangYM2.Text, out ym))
            {

            }
            else
            {
                ym = 0;
            }
            if (type == "")
            {
                type = "0";
            }
            else if (type == "v_yonghuh")
            {
                type = "1";
            }
            else if (type == "v_yonghum")
            {
                type = "2";
            }
            else
            {
                type = "0";
            }
            int? YMType = -1;
            if (ym > 0)
            {
                switch (cmbShuiLiangYM1.Text.Trim())
                {
                    case "=":
                        YMType = 0;
                        break;
                    case ">":
                        YMType = 1;
                        break;
                    case ">=":
                        YMType = 2;
                        break;
                    case "<":
                        YMType = 3;
                        break;
                    case "<=":
                        YMType = 4;
                        break;
                    case "<>":
                        YMType = 5;
                        break;
                };
            }




            PageIndex7 = PageIndex7 + 1;
            int? pagecount = 0;
            v_ywy = cmbYeWuY.Value.ToString();

            if (LoginInfo.CurrentUser.UserID == 55)
            {
                v_zhandian = "";
                v_guanlikuai = "";
            }
            //BusinessTool.WType :  1 地表水 2 地下水
            DataSet ds = _SpHelper.P_QS_GH_GuaHaoXinDXS(v_zwy, v_zwm, v_zhandian, v_guanlikuai, Convert.ToInt32(v_ywy), Convert.ToInt32(type), value, "", ym / 100, ym % 100, null, YMType, PageIndex7, 100, out pagecount, BusinessTool.WType);

            if (PageIndex7 == 1)
            {
                dtGuaHaoXtab7 = null;
            }

            if (dtGuaHaoXtab7 == null)
            {
                dtGuaHaoXtab7 = ds.Tables[0];
            }
            else
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    DataRow newdr = dtGuaHaoXtab7.NewRow();
                    foreach (DataColumn d in ds.Tables[0].Columns)
                    {
                        newdr[d.ColumnName] = dr[d.ColumnName];
                    }
                    dtGuaHaoXtab7.Rows.Add(newdr);
                }
            }

            gvGuaHaoXtab7.DataSource = dtGuaHaoXtab7;// ds.Tables[0];
            gvGuaHaoXtab7.DataBind();
            lbZongBiStab7.Text = "共" + pagecount + "笔";
        }

        /// <summary>
        /// 加载tab8页签数据
        /// </summary>
        private void LoadGridDataTab8(int v_zwy, int v_zwm, string v_zhandian, string v_guanlikuai, string v_ywy, string type, string value)
        {
            int ym = 0;
            if (rbnShuiLiangYM.Checked && cmbShuiLiangYM1.Text != "" && txtShuiLiangYM2.Text != "")
            {
                if (int.TryParse(txtShuiLiangYM2.Text, out ym))
                {
                    value = cmbShuiLiangYM1.Text + txtShuiLiangYM2.Text;
                    type = "1";
                }
                else
                {
                    type = "0";
                }

            }
            else if (type == "v_yonghuh")
            {
                type = "2";
            }
            else if (type == "v_yonghum")
            {
                type = "3";
            }
            else
            {
                type = "0";
            }
            string jiaofeije = "";
            DateTime? jiaofeirq = null;
            int? jiaofeilx = null;
            DateTime? shoudwirq = null;
            if (rbnJiaoFeiJEtab8.Checked && txtJiaoFeiJEtab8.Text.Trim().Length > 0)
            {
                jiaofeije = cbmJiaoFeiJEtab8.Text + txtJiaoFeiJEtab8.Text;
            }
            else if (rbnJiaoFeiRQtab8.Checked && txtJiaoFeiRQtab8.Text.ToString().Trim().Length > 0)
            {
                jiaofeirq = DateTime.Parse(txtJiaoFeiRQtab8.Text.ToString());
            }
            else if (rbnJiaoFeiLXtab8.Checked)
            {
                jiaofeilx = Convert.ToInt32(cbmJiaoFeiLXtab8.Value);
            }
            else if (rbnShouFeiRQtab8.Checked && txtShouFeiRQtab8.Text.ToString().Trim().Length > 0)
            {
                shoudwirq = DateTime.Parse(txtShouFeiRQtab8.Text.ToString());
            }
            int yewuyuan = Convert.ToInt32(cmbYeWuY.Value.ToString().Trim().Length == 0 ? "0" : cmbYeWuY.Value.ToString());
            DataSet ds = _SpHelper.P_YS_CX_JIAOFEIXXCX(v_zwy, v_zwm, v_zhandian == "" ? "00" : v_zhandian, v_guanlikuai == "" ? "0" : v_guanlikuai, yewuyuan, Convert.ToInt32(type), value, chkWeiDaoZtab8.Checked ? 1 : 0, jiaofeije, jiaofeirq, jiaofeilx, shoudwirq);
            dtJiaoFeitab8 = ds.Tables[0];
            gvJiaoFeitab8.DataSource = dtJiaoFeitab8;
            gvJiaoFeitab8.DataBind();
            lbZongBiStab8.Text = "共" + gvJiaoFeitab8.VisibleRowCount + "笔";
        }
        #endregion

        protected void btnTuiHuitab7_Click(object sender, EventArgs e)
        {
            //ActiveTabIndexChange(6);            
        }

        protected void btnImportExceltab7_Click(object sender, EventArgs e)
        {

        }

        protected void ASPxCallbackControl_Callback(object source, DevExpress.Web.CallbackEventArgs e)
        {
            if (e.Parameter == "GuaHaoTH")
            {
                string ids = "";
                string type = "-1";
                //挂号退回
                for (int i = 0; i < gvGuaHaoXtab7.VisibleRowCount; i++)
                {

                    ASPxCheckBox ck = (ASPxCheckBox)gvGuaHaoXtab7.FindRowCellTemplateControl(i, (GridViewDataColumn)gvGuaHaoXtab7.Columns[0], "ck");
                    if (null != ck && ck.Checked)
                    {
                        ids += ck.ToolTip + ",";
                    }

                }
                if (ids.Trim().Length > 0)
                {
                    ids = ids.Remove(ids.LastIndexOf(','));
                    _SpHelper.P_QS_CW_Update_GuaHaoXinDXS(ids, 1);
                    type = "1";
                }
                else
                {
                    ids = "0";
                    type = "-1";
                }
                e.Result = e.Parameter + "|" + type + "|" + ids;
            }
            else if (e.Parameter == "YongHuXX")
            {
                int index = Convert.ToInt32(HiddenListValue.Get("NowIndex"));
                string arr = "S_YONGHUH;S_YONGHUM;S_LIANXIR;S_LIANXIDH;S_LIANXIBM;USERNAME;SFFS;S_YOUBIAN;CWYB;S_DIZHI;CWDZ;S_YINHANGZH;S_KAIHUHM;S_KAIHUYH";
                object[] values = gvGuaHaoXtab7.GetRowValues(index, arr.Split(';')) as object[];
                string arrstring = "";
                if (values != null)
                {
                    for (int i = 0; i < 14; i++)
                    {
                        arrstring += values[i] + "，";
                    }
                }
                e.Result = e.Parameter + "|1|" + arrstring;
            }
            // 多收转过往帐+
            else if (e.Parameter == "ToGWZ")
            {
                string sUserid = HiddenListValue.Get("userid").ToString();
                int iSlym = Convert.ToInt32(HiddenListValue.Get("slym"));
                int iZwym = Convert.ToInt32(HiddenListValue.Get("zwym"));
                int iErr = 0;
                string sMsg = "";
                _SplHelper.P_YS_ZW_DUOSTOGWZ(sUserid, iSlym, iZwym, out iErr, out sMsg);
                e.Result = e.Parameter + "|" + iErr + "|" + sMsg;
            }
        }

        /// <summary>
        /// 挂号信导入
        /// 孙雪婷 修改于2017-10-20
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void UpLoadFile_FileUploadComplete(object sender, FileUploadCompleteEventArgs e)
        {
            e.CallbackData = "操作失败";
            int userid = LoginInfo.CurrentUser.UserID;
            //e.IsValid = false;
            const string UploadDirectory = "/UPLOAD/CX/";  //图片上传文件夹路径
            if (!UpLoadFile.IsValid)
            {
                //return string.Empty;
            }
            else
            {
                string fileName = Guid.NewGuid() + Path.GetExtension(UpLoadFile.FileName);  //文件名
                string filePath = Path.Combine(Server.MapPath(UploadDirectory), fileName);    //文件完整物理路径
                UpLoadFile.SaveAs(filePath);
                DataTable dt = ReadExcel(filePath);

                if (dt != null && dt.Rows.Count > 0)
                {
                    //**//comment by gdj 
                    DataTable newdt = _SpHelper.P_QS_CW_INEXCELGHXDXS(userid, 0, BusinessTool.WType).Tables[0];
                    //DataTable newdt = new DataTable();
                    //用户号, 金额, 水量年, 水量月,费用号, 收据编号, 挂号信号, 邮寄日期
                    foreach (DataRow dr in dt.Rows)
                    {
                        DataRow newdr = newdt.NewRow();
                        if (dt.Columns.Contains("用户号"))
                        {
                            newdr["S_YONGHUH"] = dr["用户号"];
                        }
                        if (dt.Columns.Contains("财务部门地址"))
                        {
                            newdr["S_CAIWUDZ"] = dr["财务部门地址"];
                        }
                        if (dt.Columns.Contains("加价金额"))
                        {
                            newdr["S_JINE"] = dr["加价金额"];
                        }
                        if (dt.Columns.Contains("水量年"))
                        {
                            newdr["S_Y"] = dr["水量年"];
                        }
                        if (dt.Columns.Contains("水量月"))
                        {
                            newdr["S_M"] = dr["水量月"];
                        }
                        if (dt.Columns.Contains("费用编号"))
                        {
                            newdr["S_FEIYONGBH"] = dr["费用编号"];
                        }
                        if (dt.Columns.Contains("收据编号"))
                        {
                            newdr["S_SHOUJUBH"] = dr["收据编号"];
                        }
                        if (dt.Columns.Contains("挂号信编号"))
                        {
                            newdr["S_GUANHAOXH"] = dr["挂号信编号"];
                        }
                        if (dt.Columns.Contains("邮寄日期"))
                        {
                            newdr["S_YOUJIRQ"] = dr["邮寄日期"];
                        }
                        newdt.Rows.Add(newdr);

                    }
                    string tablename = "PLANWATER_TEMP.P_QS_GH_GuaHaoXinDXS";
                    if (BusinessTool.InsertOracelData(newdt, tablename))
                    {
                        //e.CallbackData = "1111";

                        DataSet ds = _SpHelper.P_QS_CW_INEXCELGHXDXS(userid, 1, BusinessTool.WType);
                        if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                        {
                            e.IsValid = true;
                            e.CallbackData = ds.Tables[0].Rows[0][0].ToString();
                        }
                        else
                        {

                        }
                    }
                }
            }
        }

        private DataTable ReadExcel(string ExcelFilePath)
        {
            DataTable dt = new DataTable();
            //string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0; " +"Data Source=" +ExcelFilePath + ";Extended Properties=Excel 8.0";
            string strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties='Excel 12.0;HDR=YES';data source=" + ExcelFilePath;
            OleDbConnection Connection = new OleDbConnection(strConnection);
            Connection.Open();
            string CommandText = "";
            DataTable dtsheetName = GetWorkBookName(Connection);
            if (dtsheetName != null && dtsheetName.Rows.Count > 0)
            {
                CommandText = "select * from [" + dtsheetName.Rows[0]["TABLE_NAME"].ToString() + "]";
            }
            else
            {
                return null;
            }
            OleDbCommand comm = new OleDbCommand(CommandText, Connection);

            try
            {

                OleDbDataAdapter da = new OleDbDataAdapter(comm);
                DataSet Ds = new DataSet();
                da.Fill(Ds);
                dt = Ds.Tables[0];
            }
            catch (Exception)
            {
            }
            finally
            {
                if (Connection.State == ConnectionState.Open) Connection.Close();
            }
            return dt;

        }
        /// <summary>
        /// 获取Excel中的所有工作簿
        /// </summary>
        /// <param name="Connection">OleDbConnection对象</param>
        /// <returns></returns>
        public static DataTable GetWorkBookName(OleDbConnection Connection)
        {
            DataTable Dt = null;
            try
            {
                if (Connection.State == ConnectionState.Closed) Connection.Open();
                Dt = Connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
            }
            catch (Exception)
            {
            }
            finally
            {
                if (Connection.State == ConnectionState.Open) Connection.Close();
            }
            return Dt;
        }


        protected void btnExport_Click(object sender, EventArgs e)
        {
            int index = ASPxPageControl1.ActiveTabIndex;
            string sName = "";
            if (index == 0)
            {
                gvBenQiXXTab1.DataSource = this.dtBenQiXXTab1;
                gvBenQiXXTab1.DataBind();
                ASPxGridViewExporter1.GridViewID = "gvBenQiXXTab1";
                sName = "本期信息";
                gvBenQiXXTab1.Settings.ShowFooter = false;
            }
            else if (index == 1)
            {
                gvBenYueDZtab2.DataSource = this.dtBenYueDZTab2;
                gvBenYueDZtab2.DataBind();
                ASPxGridViewExporter1.GridViewID = "gvBenYueDZtab2";
                sName = "本月到账";
                gvBenYueDZtab2.Settings.ShowFooter = false;
            }
            else if (index == 2)
            {
                gvTuiPiaotab3.DataSource = this.dtTuiPiaotab3;
                gvTuiPiaotab3.DataBind();
                ASPxGridViewExporter1.GridViewID = "gvTuiPiaotab3";
                sName = "退票";
                gvTuiPiaotab3.Settings.ShowFooter = false;
            }
            else if (index == 3)
            {
                gvTuiKuantab4.DataSource = this.dtTuiKuantab4;
                gvTuiKuantab4.DataBind();
                ASPxGridViewExporter1.GridViewID = "gvTuiKuantab4";
                sName = "退款";
                gvTuiKuantab4.Settings.ShowFooter = false;
            }
            else if (index == 4)
            {
                gvJiHuaBGtab5.DataSource = this.dtJiHuaBGtab5;
                gvJiHuaBGtab5.DataBind();
                ASPxGridViewExporter1.GridViewID = "gvJiHuaBGtab5";
                sName = "计划变更";
                gvJiHuaBGtab5.Settings.ShowFooter = false;
            }
            else if (index == 5)
            {
                gvDuoShoutab6.DataSource = this.dtDuoShoutab6;
                gvDuoShoutab6.DataBind();
                ASPxGridViewExporter1.GridViewID = "gvDuoShoutab6";
                sName = "多收";
                gvDuoShoutab6.Settings.ShowFooter = false;
            }
            else if (index == 6)
            {
                gvGuaHaoXtab7.DataSource = this.dtGuaHaoXtab7;
                gvGuaHaoXtab7.DataBind();
                ASPxGridViewExporter1.GridViewID = "gvGuaHaoXtab7";
                sName = "挂号信";
                gvGuaHaoXtab7.Settings.ShowFooter = false;
            }
            else if (index == 7)
            {
                gvJiaoFeitab8.DataSource = this.dtJiaoFeitab8;
                gvJiaoFeitab8.DataBind();
                ASPxGridViewExporter1.GridViewID = "gvJiaoFeitab8";
                sName = "缴费";
                gvJiaoFeitab8.Settings.ShowFooter = false;
            }

            ASPxGridViewExporter1.WriteXlsToResponse(sName);
        }

        protected void btnExport2_Click(object sender, EventArgs e)
        {
            //string sName = "本期信息";
            //gvBenQiXXTab1.DataSource = this.dtBenQiXXTab1;
            //gvBenQiXXTab1.DataBind();
            //ASPxGridViewExporter1.GridViewID = "gvBenQiXXTab1";
            //sName = "本期信息";
            //gvBenQiXXTab1.Settings.ShowFooter = false;
            //ASPxGridViewExporter1.WritePdfToResponse(sName);

        }

        protected void gvGuaHaoXtab7_RowCommand(object sender, ASPxGridViewRowCommandEventArgs e)
        {
            if (e.CommandArgs.CommandName == "renew")
            {
                string id = e.CommandArgs.CommandArgument.ToString().Trim();
                 _SpHelper.P_QS_CW_Update_GuaHaoXinDXS(id, 0);
                btnChaXun_Click(sender, null);
               // Response.Write("<script>alert('恢复完成');</script>");
            }
        }
    }
}